package com.woniu.cinema.service.impl;

import java.util.Arrays;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.woniu.cinema.mapper.ActorMapper;
import com.woniu.cinema.domain.Actor;
import com.woniu.cinema.service.ActorService;

/**
 * 演员信息Service业务层处理
 * 
 * @author yy
 * @date 2021-04-16
 */
@Service
public class ActorServiceImpl implements ActorService
{
    @Autowired
    private ActorMapper actorMapper;

    /**
     * 查询演员信息
     * 
     * @param actorId 演员信息ID
     * @return 演员信息
     */
    @Override
    public Actor selectActorById(Long actorId)
    {
        return actorMapper.selectActorById(actorId);
    }

    /**
     * 查询演员信息列表
     * 
     * @param actor 演员信息
     * @return 演员信息
     */
    @Override
    public List<Actor> selectActorList(Actor actor)
    {
        return actorMapper.selectActorList(actor);
    }

    /**
     * 新增演员信息
     * 
     * @param actor 演员信息
     * @return 结果
     */
    @Override
    public int insertActor(Actor actor)
    {
        return actorMapper.insertActor(actor);
    }

    /**
     * 修改演员信息
     * 
     * @param actor 演员信息
     * @return 结果
     */
    @Override
    public int updateActor(Actor actor)
    {
        return actorMapper.updateActor(actor);
    }

    /**
     * 批量删除演员信息
     * 
     * @param actorIds 需要删除的演员信息ID
     * @return 结果
     */
    @Override
    public int deleteActorByIds(Long[] actorIds)
    {
        return actorMapper.deleteActorByIds(actorIds);
    }

    /**
     * 删除演员信息信息
     * 
     * @param actorId 演员信息ID
     * @return 结果
     */
    @Override
    public int deleteActorById(Long actorId)
    {
        return actorMapper.deleteActorById(actorId);
    }

    @Override
    public List<Actor> listAll(Long id) {

        if(id<0){
            return actorMapper.selectActorList(new Actor());
        }else{
            Actor actor = actorMapper.selectActorById(id);
            return Arrays.asList(actor);
        }

    }
}
